import request from 'umi-request';
import {history} from 'umi'

export async function getNoticePage(params = {}) {
  return request('/api/member/api-member/index/getNotice', {
    method: 'post',
    data: {
      pageNum: params.current,
      pageSize: params.pageSize,
      msgType:parseInt(params.type),
      title:params.title,
      isDone:params.isDone,
      type:2
    },
  }).then((res) => {
    if (res.flag) {
      const data = res.data;
      return {
        current: data.currPage,
        data: data.list,
        pageSize: data.pageSize,
        success: true,
        total: data.totalCount,
      };
    } else {
      return {};
    }
  });
}

export async function routeJump(record) {
  switch(record.type) {
    case 1: {history.push('/personnel/entry/newEmployees');break;}
    case 2: {history.push('');break;}//待审计路由未知
    case 3: {history.push('/personnel/turnPositive/formal');break;}
    case 4: {history.push('/personnel/entry/contract');break;}
    case 5: {history.push('/personnel/turnPositive/salaryInfo');break;}
    case 6: {history.push('/recruitment/hire');break;}
  }
  return request('/api/member/api-member/index/updateNotice', {
    method: 'post',
    data: {
      id: record.id,
      isRead: 1,
    },
  })
}
